package com.doradance.app.home;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.doradance.R;
import com.doradance.account.utils.CustomView;
import com.doradance.account.utils.GlideRoundTransform;
import com.doradance.account.utils.XCRoundRectImageView;
import com.doradance.entity.IndexEntity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.pachong.android.baseuicomponent.adapter.RecyclerViewBaseAdapter;
import com.pachong.android.framework.httprequest.volleyadaptee.VolleyHttp;
import com.pachong.android.frameworkbase.utils.EasyToast;


import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/2/22.
 */

public class HomeStarAdapter extends RecyclerViewBaseAdapter<IndexEntity.StarStudentsBean> {


    public HomeStarAdapter(Context con) {
        super(con);
    }

    @Override
    public RecyclerView.ViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new TypeHolder(setAdapterViewItem(parent, R.layout.item_star));
    }

    @Override
    public void onBindHolder(RecyclerView.ViewHolder viewHolder, int position) {
        TypeHolder holder = (TypeHolder) viewHolder;
        final IndexEntity.StarStudentsBean bean = getData().get(position);
        Glide.with(getContext()).load(bean.getCover()).asBitmap().dontAnimate()
                .placeholder(R.mipmap.init_logo).into(holder.mIvTypeIcon);
        holder.mTvTypeName.setText(bean.getUsername());
        holder.mTvTypeNick.setText(bean.getStage_name());
        setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                StarStudentActivity.start(getContext(),getData().get(position).getId());
            }
        });
    }

    class TypeHolder extends RecyclerView.ViewHolder {

        @Bind(R.id.ivTypeIcon)
        ImageView mIvTypeIcon;
        @Bind(R.id.tvTypeName)
        TextView mTvTypeName;
        @Bind(R.id.tvTypeNick)
        TextView mTvTypeNick;

        public TypeHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
